package ${package.Controller};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import java.util.List;
import ${cfg.dubboServicePackage}.${entity}DubboService;
import ${cfg.entityVOPackage}.${entity}VO;

/**
* <p>
* ${table.comment!} 前端控制器
* </p>
*
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/admin/<#if entity??>${entity ?lower_case}</#if>")
<#if swagger2>
@Api(tags = "${cfg.TablePrefix}${entity ?lower_case}", description = "${table.comment!}接口")
</#if>
<#if kotlin>
    class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {

    </#if>
    private static final Logger logger = LoggerFactory.getLogger(${table.controllerName}.class);

    @Autowired
    ${entity}DubboService ${entity ?uncap_first}DubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询${table.comment!}分页")
    public ApiResult page(${entity}VO ${entity ?uncap_first}VO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(${entity ?uncap_first}DubboService.findPageByVO(${entity ?uncap_first}VO,pageNum,pageSize));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询${table.comment!}列表")
    public ApiResult list(${entity}VO ${entity ?uncap_first}VO) throws Exception {
        return ResponseUtil.ok(${entity ?uncap_first}DubboService.listByVo(${entity ?uncap_first}VO));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个${table.comment!}")
    public ApiResult load(@RequestParam String id) throws Exception {
        return ResponseUtil.ok(${entity ?uncap_first}DubboService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存${table.comment!}信息")
    public ApiResult save(@RequestBody ${entity}VO ${entity ?uncap_first}VO) throws Exception {
        ${entity ?uncap_first}DubboService.saveOrUpdate(${entity ?uncap_first}VO);
        return ResponseUtil.ok("success");
    }

    @PostMapping("/del")
    @ApiOperation(value = "删除${table.comment!}")
    public ApiResult del(@RequestBody List<${entity}VO> ${entity ?uncap_first}VOList) throws Exception {
        ${entity ?uncap_first}DubboService.removeByListVo(${entity ?uncap_first}VOList);
        return ResponseUtil.ok("success");
    }

    /*@PostMapping("/export")
    @ApiOperation(value = "导出excel")
    public Object export(@RequestParam Map<String, Object> params) throws Exception {
        return ResponseUtil.ok(${entity ?uncap_first}DubboService.findMapByList(params));
    }*/
}
</#if>